<template>
  <ex-dialog
    width="1200px"
    class="ex-diolog"
    :title="title"
    :visible="visible"
    :close-on-click-modal="false"
    @closeDialog="handleClose"
  >
    <div class="main" v-loading="loading">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="" prop="name" label-width="0">
          <el-row>
              <el-col :span="24">
                <el-form-item label="" prop="rejectReason" label-width="0"> 
                  <el-input
                    type="textarea"
                    maxlength="500"
                    :autosize="{ minRows: 10, maxRows: 20}"
                    placeholder="请输入拒绝原因"
                    v-model="ruleForm.rejectReason">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
        </el-form-item>
        <el-form-item>
          <el-button @click="handleClose('ruleForm')">取消</el-button>
          <el-button type="primary" @click="submitForm('ruleForm')">同意</el-button>
        </el-form-item>
      </el-form>
    </div>
      
  </ex-dialog>
</template>
<script>
import Loading from "@/components/Loading/index";
// api
import {
    refundRefuse,
  } from "@/api/syFundManagement/zhuanReturn";
export default {
  components: {
    Loading,
  },
  props: {
    visible: Boolean,
    row: Object,
  },
  data() {
   
    return {
      labelWidth: "150px",
      inputWidth: "420px",
      title: "驳回原因",
      loading: false,
      disabled: false,
      AgreeLoading: false,
      ruleForm: {
        customerEquityCardId: '',//	用户卡id
        customerId: '',//	用户id
        orderId: '',//订单id
        rejectReason: '',//拒绝原因
      },
      
      rules: {
        rejectReason: [
          {required: true,message: "请输入拒绝原因",trigger: ["change"]}
        ],
        
        
      },
      
    };
  },
  computed: {},
  created() {
    this.ruleForm = {
        customerEquityCardId: this.row.customerEquityCardId,
        customerId: this.row.customerId,
        orderId: this.row.orderId,
      }
  },
  mounted() {
    
  },
  computed: {},
  methods: {
    
    //取消
    handleClose(formName) {
      this.$emit("update:visible", false);
    },
    //勾选活动奖励
    
    submitForm(formName) {
      console.log(this.twoForm);
      //创建确定
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.AgreeLoading = true
          var data = {
            ...this.ruleForm
          }
          refundRefuse(data).then(res => {
              setTimeout(() => {
                this.handleClose()
                this.$message.success('驳回成功')
                this.$emit('success')
                this.AgreeLoading = false
              }, 1000);
            }).finally(()=>{
              this.AgreeLoading = false
            })
          
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    
  }
};
</script>
<style lang="scss" scoped>
.ex-diolog {
  ::v-deep .ex--dialog--footer {
    border: none !important;
    padding: 0 !important;
  }

  ::v-deep .ex--dialog--main {
    padding: 10px 20px !important;
  }
}
.title{
  font-size: 18px;
  font-weight: bold;
  color: #1890ff;
  padding: 10px 0;
  border-bottom: 4px solid #1890ff;
  margin-bottom: 20px;
  display: flex;
  justify-content: flex-start;
  span{
    padding-top: 8px;
  }
}
.checkBox{
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  .el-select{
    margin: 0 8px;
    width: 200px;
  }
  .el-input{
    width: 100px;
    margin: 0 8px;
  }
  .el-form-item{
    display: flex;
  }
}
.timeBox{
  display: flex;
  justify-content: flex-start;
  align-items: center;
  .el-input{
    width: 110px;
    margin: 0 8px;
  }
  span{
    margin: 0 8px;
  }
}
.inpBox{
  display: flex;
  justify-content: flex-start;
  // align-items: center;
  .blue{
    color: #1890ff;
    margin-top: 10px;
  }
  .el-input{
    width: 150px;
    margin: 0 8px;
  }
  .el-select{
    width: 150px;
  }
  
  ::v-deep .el-input-group__append{
    padding: 0 8px !important;
  }
}
.stockNum{
    margin: 8px 0 0 5px;
  }
.tipsBox{
  margin: 14px 0;
  color: red;
}
.calculateBox{
  display: flex;
  justify-content: center;
  .biaoG{
    margin-right: 20px;
    border: 1px solid #dfe6ec;
    .head{
      display: flex;
      width: 400px;
      border-bottom: 1px solid #dfe6ec;
      div{
        display: flex;
        flex: 1;
        justify-content: center;
        align-items: center;
        font-size: 14px;
        color: #333;
        height: 50px;
      }
      div:first-child{
        border-right: 1px solid #dfe6ec;
      }
    }
  }
}
.statusBox{
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  margin-top: 50px;

  .status{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-bottom: 50px;
    .tips{
      margin-top: 20px;
    }
  }
}
.el-select{
  width: 100%;
}
.button_box{
  display: flex;
  justify-content: center;
  margin-top: 24px;
}
</style>
